home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
AppleEvents
/
Simple Descriptors
/
AESimpleDescriptor.h
< prev
Wrap
Text File
|
2000-06-23
|
2KB
|
59 lines
// AESimpleDescriptor.h
#ifndef AESimpleDescriptor_h
#define AESimpleDescriptor_h
#ifndef Integers_h
#include "Integers.h"
#endif
#ifndef AEDescriptor_h
#include "AEDescriptor.h"
#endif
#ifndef ConstData_h
#include "ConstData.h"
#endif
template < uint32 aeType, class ContainedType >
class AESimpleDescriptor: public AEDescriptor
{
public:
AESimpleDescriptor() {}
AESimpleDescriptor( const ContainedType& value )
: AEDescriptor( ConstData( &value, sizeof( ContainedType ) ), StaticType() )
{}
static AEType StaticType() { return AEType( aeType ); }
bool TypeIsCorrect() const { return Type() == StaticType(); }
bool SizeIsCorrect() const
{ return AEDescriptor::Value().Size() == sizeof( ContainedType ); }
const ContainedType& Value() const
{
Assert( Allocated() );
Assert( TypeIsCorrect() );
Assert( !AEDescriptor::Value().IsEmpty() );
Assert( SizeIsCorrect() );
return *static_cast< ContainedType * >( AEDescriptor::Value().Pointer() );
}
void Set( const ContainedType& value )
{
Assert( Allocated() );
Assert( TypeIsCorrect() );
Assert( !AEDescriptor::Value().IsEmpty() );
Assert( SizeIsCorrect() );
*static_cast< ContainedType * >( AEDescriptor::Value().Pointer() ) = value;
}
void operator=( const ContainedType& newValue )
{ Set( newValue ); }
};
typedef AESimpleDescriptor< typeShortInteger, int16 > AEInt16;
typedef AESimpleDescriptor< typeLongInteger, int32 > AEInt32;
typedef AESimpleDescriptor< typeMagnitude, uint32 > AEUInt32;
typedef AESimpleDescriptor< typeFixed, Fixed > AEFixed;
#endif